<?php
$userid = islogin();
$oCart = new Cart();
$cartlist = $oCart->get_all('*', array('userid' => $userid), array('time' => 'DESC'));
if(empty($cartlist['list'])){
	if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
		$url = PUB_DIR.'goods/';
	}else{
		$url = WEB_DIR.'index.php?mdl=goods';
	}
	sysinfo(array(
		'title' => '您的购物车中暂无商品，赶快选择心爱的商品吧！',
		'btns' => array(
			'去选商品' => $url,
		),
	), $url, 5000);
}

	$vars['cartlist'] = array();
	foreach($cartlist['list'] as $row){
		if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
			if(!empty($row['filename'])){
				$row['url'] = PUB_DIR.'goods/'.$row['filename'].'.html';
			}else{
				$row['url'] = PUB_DIR.'goods/'.time_to_path($row['addtime']).'/'.$row['goodsid'].'.html';
			}
		}else{
			$row['url'] = WEB_DIR."index.php?mdl=row&do=view&id={$row['id']}";
		}
		$vars['cartlist'][] = $row;
	}
	$vars['goods_cost'] = $cartlist['cost'];
	$vars['goods_weight'] = format_weight_out($cartlist['weight'], 'kg');


// 精品推荐
$oGoods = new Goods();
$goodslist_good = $oGoods->get_list('*', array('recommend' => 'good'), null, 1, 12);
foreach($goodslist_good['list'] as $key => $goods){
	$goods_query = empty($goods_query) ? '' : '?'.implode('&', $goods_query);
	if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
		if(empty($goods['filename'])){
			$goods['url'] = PUB_DIR.'goods/'.time_to_path($goods['addtime']).'/'.$goods['id'].'.html'.$goods_query;
		}else{
			$goods['url'] = PUB_DIR.'goods/v/'.$goods['filename'].'.html'.$goods_query;
		}
	}else{
		$goods['url'] = WEB_DIR."index.php?mdl=goods&do=view&id={$goods['id']}";
	}
	$goodslist_good['list'][$key] = $goods;
}
$vars['goodslist_good'] = $goodslist_good['list'];
?>